var stream;
function start(){
	stream = pi.comet.get("examples/simple/simple.php",read,disable);
	startButton.attribute.set("disabled","disabled").event.removeListener("click",start);
	stopButton.attribute.remove("disabled").event.addListener("click",stop);
	textbox.update("");
}

function read(_response){
	textbox.element.value+="\n"+_response;
}

function stop(){
	stream.abort();
	disable();
}

function disable(){
	startButton.attribute.remove("disabled").event.addListener("click",start);
	stopButton.attribute.set("disabled","disabled").event.removeListener("click",stop);
}

var startButton = new pi.element(pi.get("start")).event.addListener("click",start), 
stopButton = new pi.element(pi.get("stop")).attribute.set("disabled","disabled"), 
textbox = new pi.element(pi.get("monitor")).attribute.set("readonly","readonly");